<template>
	<view :style="themeColor">
		<view class="page">
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout denglu_flex_0">
				<view class='flex flex-wrap align-center justify-center denglu_fd0_0'>
					<image class='denglu_fd0_0_c0' mode="aspectFit" src='../../../static/images/logo.png'></image>
				</view>
				<view class='flex flex-wrap align-center authenticateNow_fd1_0' @tap.stop="pickerDiy16950834302200=true">
					<image class='denglu_fd0_1_c01' mode="aspectFit" src='../../../static/images/align_l.png'
						style="margin-right: 28rpx;"></image>
					<!-- <text class='authenticateNow_fd1_0_c0'>选择公司</text> -->
					<input class='authenticateNow_fd1_4_c1' type="text" :placeholder="`请选择公司`" confirm-type="done" :maxlength="-1"
						placeholder-style="color:#999;font-size:28rpx" v-model="classification_label" disabled="true" />
					<!-- <image class='authenticateNow_fd1_0_c2' mode="aspectFit" :src='STATIC_URL+"137.png"'
				    style="margin-left: 10rpx;"></image> -->
				</view>
				<view class='flex flex-wrap align-center denglu_fd0_1'>
					<image class='denglu_fd0_1_c0' mode="aspectFit" :src='STATICA_URL+"3.png"'></image>
					<input class='flex-sub denglu_fd0_1_c1' type="text" :placeholder="`请输入账号`" confirm-type="done" :maxlength="11"
						placeholder-style="color:#999;font-size:28rpx" v-model="account" />
				</view>
				<view class='flex flex-wrap align-center denglu_fd0_2'>
					<image class='denglu_fd0_1_c0' mode="aspectFit" :src='STATICA_URL+"4.png"'></image>
					<benben-flex-password-diy v-model="password" class-name="flex flex align-center denglu_fd0_2_c1"
						:placeholder="'请输入密码(6~12位字母+数字)'" :maxlength="12" :default-type='true'
						placeholder-style="color:#999;font-size:28rpx">
						<template #show>
							<text class='fu-iconfont2  denglu_fd0_2_c1_icon1' data-type="show">&#xE837;</text>
						</template>
						<template #hide>
							<text class='fu-iconfont2  denglu_fd0_2_c1_icon1' data-type="hide">&#xEBCC;</text>
						</template>
					</benben-flex-password-diy>
				</view>
				<benben-picker ref="benbenWritePickerCodepicker23211" :visible.sync="pickerDiy16950834302200"
					:label.sync='classification_label' :value.sync='classification_value' :options='classification_list'
					mode='selector' :mask-show='true' :timeout='true' :picker-height='88' default-type='tenantId'
					@change='changeFenlei' :default-props='{"label":"companyName","value":"tenantId"}'>
					<template #picker-header>
						<view class='flex flex-wrap align-center justify-between authenticateNow_picker2_0'>
							<text class='authenticateNow_picker2_0_c0'
								@tap="$refs.benbenWritePickerCodepicker23211.cancel()">取消</text>
							<u-search placeholder="可输入关键字进行搜索" v-model="keyword" :show-action="true" :animation="true"
								:clearabled="false" @search='search' @custom='search'></u-search>
							<text class='authenticateNow_picker2_0_c2'
								@tap="$refs.benbenWritePickerCodepicker23211.pickerConfirm()">确定</text>
						</view>
					</template>
				</benben-picker>
				<view class='flex flex-direction-row-reverse flex-wrap align-center denglu_fd0_3'>
					<text class='denglu_fd0_3_c0' @tap.stop="handleJump">返回</text>
				</view>
				<button class='denglu_fd0_4' @tap.stop="onlogonFunc()">登录</button>



			</view>

			<!---flex布局flex布局结束-->


		</view>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},


		data() {
			return {
				"pickerDiy16950834302200": false,
				"classification_list": [],
				"classification_value": "1",
				"classification_label": "",
				tenantId: '',
				"id_tk": false,
				"dataList": {
					"userinfo": {
						"user_token": "",
						"id": "",
						"avatar": "",
						"real_name": "",
						"nickname": "",
						"email": "",
						"gender": "",
						"mobile": "",
						"birthday": "",
						"client_id": "",
						"phone": ""
					}
				},
				"password": "",
				"account": "",
				appVersion: '',
				pingtai: '',
				isxianshi: 100,
				keyword: ''
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			uni.removeStorageSync('venueInfo')
			uni.removeStorageSync('keyPhone');
			uni.removeStorageSync('code');
			uni.removeStorageSync('iv');
			uni.removeStorageSync('encryptedData');
			this.getgongsi()
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {
			arr: [{
				id: 3,
				name: 王五
			}]
		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			async search(e) {
				console.log(e, 'eeeeeeeeee');
				if (!e.trim()) {
					await this.getgongsi(); // 确保完成后返回
					return;
				}
				await this.getgongsi(); // 等待 getgongsi 完成
				this.comego(e); // 然后调用 comego
			},
			comego(e) {
				let arr = this.classification_list.filter(item => item.companyName.includes(e));
				console.log(arr, '@@@@@@@@@@@@')
				if (arr.length == 0) {
					return false
				} else {
					this.classification_list = arr
				}
			},

			async getgongsi() {
				let res = await this.$api.get(global.apiUrls.tenant, {
					companyName: this.keyword
				});
				if (res.data.code != 200) {
					this.$message.info(res.data.msg)
					return
				}
				this.classification_list = res.data.data.voList
				console.log(this.classification_list, 'this.classification_list')
			},
			handleJump() {
				uni.reLaunch({
					url: '/pages/tabBar/passwordLogin/passwordLogin'
				})
			},
			changeFenlei(e) {
				this.tenantId = e.obj.tenantId
				console.log(this.tenantId, 'this.tenantId')

			},
			//登录
			async onlogonFunc() {
				if (!validate(this.tenantId, 'require')) {
					this.$message.info('请选择公司');
					return false;
				}
				if (!validate(this.account, 'require')) {
					this.$message.info('请输入账号');
					return false;
				}

				if (!validate(this.password, 'require')) {
					this.$message.info('请输入密码');
					return false;
				}

				// if (this.id_tk === false) {
				//   this.$message.info('请阅读并同意《用户注册协议》与《隐私政策》');
				//   return false;
				// }
				//请求方法
				//数据验证

				let res = await this.$api.post(global.apiUrls.login, {
					username: this.account,
					password: this.password,
					tenantId: this.tenantId,
					clientId: '0dffd4077089505743e6d68b39309c5b',
					grantType: "password",
					enableCaptcha: 0

				});
				uni.removeStorageSync('USER_TOKEN')
				uni.removeStorageSync('USER_INFO')
				if (res.data.code != 200) {
					this.$message.info(res.data.msg);
					return
				}
				this.dataList = res.data.data
				this.$store.commit('saveToken', this.dataList.access_token)
				this.$store.commit('updateUserInfo', this.dataList)
				this.toHomeDiy();
			},
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));

	}

	.denglu_flex_0 {
		padding: 0rpx 40rpx 0rpx 40rpx;
	}

	.denglu_fd0_8_c3 {
		color: var(--benbenFontColor2);
		font-size: 26rpx;
		font-weight: 400;
		line-height: 33rpx;
	}

	.denglu_fd0_8_c2 {
		color: var(--benbenFontColor4);
		font-size: 26rpx;
		font-weight: 400;
		line-height: 33rpx;
	}

	.denglu_fd0_8_c1 {
		color: var(--benbenFontColor2);
		font-size: 26rpx;
		font-weight: 400;
		line-height: 33rpx;
		margin: 0rpx 0rpx 0rpx 16rpx;
	}

	.denglu_checkfd0_8_c0_c0_c0 {
		width: 32rpx;
		height: 32rpx;
	}

	.denglu_fd0_8 {
		position: fixed;
		bottom: calc(48rpx + var(--window-bottom));
		left: 0rpx;
		width: 750rpx;
	}

	.denglu_fd0_7_c0 {
		width: 70rpx;
		height: 70rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.denglu_fd0_7 {
		margin: 40rpx 0rpx 0rpx 0rpx;
	}

	.denglu_fd0_6_c1 {
		color: var(--benbenFontColor2);
		font-size: 26rpx;
		font-weight: 400;
		line-height: 37rpx;
		margin: 0rpx 10rpx 0rpx 10rpx;
	}

	.denglu_fd0_6_c0 {
		background: #EEEEEE;
		width: 156rpx;
		height: 1rpx;
		margin: 10rpx 0rpx 10rpx 0rpx;
		transform: scaleY(0.5);
		border-radius: 1rpx 1rpx 1rpx 1rpx;
	}

	.denglu_fd0_6 {
		margin: 70rpx 0rpx 0rpx 0rpx;
	}

	.denglu_fd0_5_c1 {
		background: rgba(153, 153, 153, 1);
		width: 1rpx;
		height: 20rpx;
		margin: 0rpx 20rpx 0rpx 20rpx;
		transform: scaleX(0.5);
	}

	.authenticateNow_fd1_0 {
		border-bottom: 1px solid #eee;
		padding: 32rpx 32rpx 32rpx 0rpx;
		margin-top: 180rpx;
	}

	.authenticateNow_fd1_0_c0 {
		font-size: 28rpx;
		font-weight: 400;
		color: #999;
	}

	.authenticateNow_fd1_4_c1 {
		text-align: left;
		font-size: 28rpx;
	}

	.denglu_fd0_5_c0 {
		color: var(--benbenFontColor2);
		font-size: 28rpx;
		font-weight: 400;
		line-height: 40rpx;
	}

	.authenticateNow_fd1_0_c2 {
		width: 14rpx;
		height: 22rpx;
	}

	.denglu_fd0_5 {
		margin: 51rpx 0rpx 0rpx 0rpx;
	}

	.denglu_fd0_4 {
		background: rgba(1, 50, 189, 1);
		border-radius: 50rpx 50rpx 50rpx 50rpx;
		font-size: 32rpx;
		color: var(--benbenFontColor3);
		width: 580rpx;
		height: 88rpx;
		line-height: 88rpx;
		margin: 107rpx 45rpx 0rpx 45rpx;
	}

	.denglu_fd0_3_c0 {
		color: #167deb;
		font-size: 28rpx;
		font-weight: 400;
		line-height: 40rpx;
	}

	.authenticateNow_picker2_0_c2 {
		color: #333333;
		font-size: 32rpx;
		font-weight: 400;
	}

	.authenticateNow_picker2_0_c0 {
		color: #BFBFBF;
		font-size: 32rpx;
		font-weight: 400;
	}

	.authenticateNow_picker2_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		padding: 0rpx 32rpx 0rpx 32rpx;
		line-height: 88rpx;
		border-radius: 25rpx 25rpx 0rpx 0rpx;
		background-size: 100% auto !important;
	}

	.denglu_fd0_3 {
		margin: 32rpx 0rpx 0rpx 0rpx;
	}

	.denglu_fd0_2_c1_icon1 {
		width: 88rpx;
		line-height: 88rpx;
		text-align: center;
		font-size: 40rpx;
	}

	::v-deep .denglu_fd0_2_c1 {
		height: 88rpx;
		width: 580rpx;
		font-size: 28rpx;
		margin: 0rpx 0rpx 0rpx 32rpx;
		line-height: 40rpx;
		font-weight: 400;
		color: var(--benbenFontColor0);
	}

	.denglu_fd0_2 {
		border-bottom: 1px solid rgba(234, 234, 234, 1);
		//padding: 0rpx 0rpx 0rpx 32rpx;
	}

	.denglu_fd0_1_c1 {
		color: var(--benbenFontColor0);
		font-size: 28rpx;
		font-weight: 400;
		line-height: 40rpx;
		margin: 0rpx 0rpx 0rpx 32rpx;
		height: 88rpx;
	}

	.denglu_fd0_1_c0 {
		width: 40rpx;
		height: 40rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.denglu_fd0_1_c01 {
		width: 36rpx;
		height: 36rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.denglu_fd0_1 {
		border-bottom: 1px solid rgba(234, 234, 234, 1);
		//padding: 0rpx 32rpx 0rpx 32rpx;
		margin: 0rpx 0rpx 32rpx 0rpx;
	}

	.denglu_fd0_0_c0 {
		width: 172rpx;
		height: 172rpx;
		border-radius: 16rpx;
	}

	.denglu_fd0_0 {
		margin: 167rpx 0rpx 0rpx 0rpx;
	}
</style>